﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
namespace AnyOffice.general.system.user
{
    public partial class user_dept : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["usbkey"] != null)
            {
                StringBuilder builder = new StringBuilder();
                builder.Append("<script type=\"text/javascript\" language=\"javascript\">\n");
                builder.Append("alert('初始化USB KEY成功！');\n");
                builder.Append("</script>\n");
                this.Page.RegisterStartupScript("pop", builder.ToString());
            }
            int num = (Request.QueryString["dept_id"] == null) ? 0 : int.Parse(Request.QueryString["dept_id"].ToString());
            this.ViewState["DeptId"] = num;
            DataTable table = new DepartmentDao().SelectByDeptId(base.Conn, num);
            if (table.Rows.Count > 0)
            {
                this.lblDeptName.Text = table.Rows[0]["DeptName"].ToString();
            }
            DataTable table2 = new UsersDao().SelectByDeptId(base.Conn, num);
            if (table2.Rows.Count == 0)
            {
                this.lblMessage.Text = base.ShowMessage("尚未定义用户");
            }
            else
            {
                this.lblUserCount.Text = table2.Rows.Count.ToString();
                this.Repeater1.DataSource = table2;
                this.Repeater1.DataBind();
            }
        }
    }
}
